package com.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class TestServlet
 */
@WebServlet("/test")
public class TestServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */

	public TestServlet() {
		System.out.println("Constructor...");
	}

	@Override
	public void init() throws ServletException {
		System.out.println("init...");
	}
	
	protected void service(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		System.out.println("test...");

		request.setAttribute("msg", "servlet3.0 & jetty...");

		request.getSession().setAttribute("session", "session MSG");
		
		request.getServletContext().setAttribute("app", "app msg");
		
		request.getRequestDispatcher("/test.jsp").forward(request, response);
	}

}
